import React, { useRef, useEffect } from 'react'
import Chlild from './Chlild'

export default function UseRef () {
  const inpRef = useRef()
  const childRef = useRef()

  useEffect(() => {
    inpRef.current.focus()
  }, [])
  const change = () => {
    console.log('--ref--')
    childRef.current.setCount(240)
  }
  return (
    <div>
      UseRef
      <p>
        <input type='text' ref={inpRef} />
      </p>
      <p>
        <button onClick={change}>change</button>
      </p>
      <hr />
      <Chlild ref={childRef} />
    </div>
  )
}
